package com.nfc.base.Entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Type;

@Entity
@Table(name="user_roles")
public class UserRole {

	private int user_role_id;
	private User user_id;
	private String role;
	
	private Staff created_by;
	private Date created_on;
	
	private Staff changed_by;
	private Date changed_on;
	
	@Id
	@Column(name="user_role_id", unique = true, nullable = false)
	@SequenceGenerator(name="user_roles_role_id_seq", sequenceName="user_roles_user_role_id_seq")
	@GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="user_roles_role_id_seq")
	
	public int getUser_role_id() {
		return user_role_id;
	}
	public void setUser_role_id(int user_role_id) {
		this.user_role_id = user_role_id;
	}
	
	@OneToOne
	@JoinColumn(name="user_id")
	public User getUser_id() {
		return user_id;
	}
	public void setUser_id(User user_id) {
		this.user_id = user_id;
	}
	
	@Column(name="role")
	public String getRole() {
		return role;
	}
	public void setRole(String role) {
		this.role = role;
	}
	
	@ManyToOne
	@JoinColumn(name="created_by", referencedColumnName = "staff_id")
	public Staff getCreated_by() {
		return created_by;
	}
	public void setCreated_by(Staff created_by) {
		this.created_by = created_by;
	}
	

	@Column(name="created_on")	
	@Type(type="date")
	@Temporal(TemporalType.DATE)
	public Date getCreated_on() {
		return created_on;
	}
	public void setCreated_on(Date created_on) {
		this.created_on = created_on;
	}

	@ManyToOne
	@JoinColumn(name="changed_by", referencedColumnName = "staff_id")
	public Staff getChanged_by() {
		return changed_by;
	}
	public void setChanged_by(Staff changed_by) {
		this.changed_by = changed_by;
	}

	@Column(name="changed_on")	
	@Type(type="date")
	@Temporal(TemporalType.DATE)	
	public Date getChanged_on() {
		return changed_on;
	}
	public void setChanged_on(Date changed_on) {
		this.changed_on = changed_on;
	}
	
	
	
	
}
